<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>财务对帐</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/icon.css"/>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/demo.css"/>
	<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.min.js"></script>
	<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.easyui.min.js"></script>
	<script src="${pageContext.request.contextPath}/plugins/jQuery/easyui-lang-zh_CN.js"></script>
	<script src="${pageContext.request.contextPath }/admin/js/easyui_mergecell.js"></script>
	<script src="${pageContext.request.contextPath }/admin/js/export.js"></script>
	<script type="text/javascript">
		$(function(){
		    
		     $('#station').combobox({
				valueField:'station_id', //值字段
				textField:'station_name', //显示的字段
				url:'${pageContext.request.contextPath }/admin/station/findStationByKind/1',
				onLoadSuccess : function(data) {
		            $('#station').combobox("setValue",-1);
	        	}
	        });
	        
			loadTable();
			$('#dg').dialog('close');
			
		});
		
		function loadTable(){
		    
		       //设置时间  
			var curr_time = new Date();     
		  	var s = $("#start_time").textbox('getValue');
		   	var e = $("#end_time").textbox('getValue');
		   
		   	if(s != null && s != '' && e !=null && e!=''){
		       $("#start_time").textbox("setValue",s);
		       $("#end_time").textbox("setValue",e);
		   	}else{
		       $("#start_time").textbox("setValue",myformatter(curr_time)); 
		       $("#end_time").textbox("setValue",myformatter(curr_time));
		   	}
		
			$('#dg').datagrid({
				rownumbers:true,
				singleSelect:true,
				pagination:false,
		 		url:'${pageContext.request.contextPath }/admin/checkacct/assignNewlist',
		 		queryParams:{
		 			 stationid:$('#station').combobox("getValue"),
		 			 startDate:$("#start_time").textbox('getValue'),
		 			 endDate:$("#end_time").textbox('getValue')
		 		},
		 		rowStyler: function(index,row){
					if (row.cust_name=="站点合计" || row.cust_name=="汇总统计"){
		//				return 'background-color:#6293BB;color:#fff;font-weight:bold;';
						return 'font-weight:bold;';
					}
				},
	    		columns:[[
					{field:'station_name',title:'站点信息',align:'center',width:200,formatter: function (value, row, index) {
						var str=value+"<br/>"+row.station_master;
						return str;		
					}},
					{field:'cust_name',title:'客户信息',align:'center',width:160,formatter: function (value, row, index) {
						var str=value+"<br/>"+row.mobile;
						return str;		
					}},
					{field:'create_time',title:'日期',align:'center',width:100},
					{field:'00str',title:'虚拟充值',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}},
					{field:'01str',title:'线下充值',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}},
					{field:'02str',title:'支付宝充值',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}},
					{field:'03str',title:'微信充值',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}},
					{field:'04str',title:'银联充值',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}},
					{field:'05str',title:'活动充值',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}},
					{field:'06str',title:'代金券充值',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}},
					{field:'total',title:'汇总',align:'center',width:100,formatter: function (value, row, index) {
						if(value=="￥0.00"){
							return "";
						}else{
							return value;
						}			
					}}
					
	 			]],
				onLoadSuccess:function(data){
 					$(this).datagrid("autoMergeCells",['station_name','cust_name']);
				}
			});
		}
		
		 //指定列求和
        function compute(colName) {
            var rows = $('#dg').datagrid('getRows');
            var total = 0;
            for (var i = 0; i < rows.length; i++) {
                total += parseFloat(rows[i][colName]);
            }
            return total;
        }
		
		function myformatter(date){  
		      var y = date.getFullYear();  
		      var m = date.getMonth()+1;  
		      var d = date.getDate();  
		      return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);  
		}  
		          
		function myparser(s){  
		    if (!s) return new Date();  
		    var ss = (s.split('-'));  
		    var y = parseInt(ss[0],10);  
		    var m = parseInt(ss[1],10);  
		    var d = parseInt(ss[2],10);  
		    if (!isNaN(y) && !isNaN(m) && !isNaN(d)){  
		        return new Date(y,m-1,d);  
		    } else {  
		        return new Date();  
		    }  
		} 	

		// 打开一个新的选项卡，并制定选项卡的名称
		function show(url,name){
			parent.window.addTab(name,url);
		}
		
		function findData(){
			loadTable();
		}
		
		function toExcel(){
			$('#ff').submit();
//			Export('导出excel', $('#dg'));
		}
		
		function Export(strXlsName, exportGrid) {
		/*  
		    var f = $('<form action="${pageContext.request.contextPath }/order/exportexcel" method="post" id="fm1"></form>');  
		    var i = $('<input type="hidden" id="txtContent" name="txtContent" />');  
		    var l = $('<input type="hidden" id="txtName" name="txtName" />');  
		    i.val(ChangeToTable(exportGrid));  
		    i.appendTo(f);  
		    l.val(strXlsName);  
		    l.appendTo(f);  
		    f.appendTo(document.body).submit();  
		    document.body.removeChild(f);  
		    */
		}  
	</script>
	<style type="text/css">
		body{
		font-family:'微软雅黑';}
	</style>
  </head>
  
  <body>
    <table id="dg" title="财务对帐" toolbar="#searchtool" loadMsg="正在查询中，请稍后..." style="width:98%;height:700px;"></table>
    <div id="searchtool" style="padding:5px;height:auto;">
    	<form action="${pageContext.request.contextPath}/admin/checkacct/exportAssignNewlist" method="post" id="ff">  
	       <span style="margin:0px 12px;">站点:</span><input id="station" name="stationid" class="easyui-textbox" style="width:180px;height:26px"/> 
	       <span style="margin:0px 12px;">时间:</span><input id="start_time" name="startDate" class="easyui-datebox" data-options="formatter:myformatter,parser:myparser" style="width:120px" value="${today }"> -- <input id="end_time" name="endDate" class="easyui-datebox" data-options="formatter:myformatter,parser:myparser" style="width:120px"  value="${today }">
	       <a href="javascript:findData()" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width:100px;margin:0px 3px;">查询</a>
	       <a href="javascript:findData()" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" style="width:100px;margin:0px 3px;">刷新</a>
	       <c:if test="${LOGIN_USER.ROLE ne 8 }">
	       <a href="javascript:toExcel()" class="easyui-linkbutton" data-options="iconCls:'icon-my-save'" style="width:100px;margin:0px 3px;">导出Excel</a>
	       </c:if>
	    </form>
    </div>
  </body>
</html>
